<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Application Test</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <script src="../../public/javascripts/prototype.js" type="text/javascript"></script>
  <script src="assets/unittest.js" type="text/javascript"></script>
  
  <script src="../../public/javascripts/application.js" type="text/javascript"></script>
  <script src="../../public/javascripts/scriptaculous.js" type="text/javascript"></script>
  
  <link rel="stylesheet" href="assets/unittest.css" type="text/css" />
</head>
<body>

<div>
	These are DOM that the test can act on. (aka. Mock DOM)
	<div id="content"></div>
</div>

<div id="content">

  <div id="header">
    <h1>Application Test</h1>
    <p>
      This file tests <strong>application.js</strong>. Application JS holds a bunch of miscellaneous functions that
      we use throughout the application.
    </p>
	<p>Currently testing the following functions</p>
    <ul> 
    	<li>flash_message(): flash a message to the user, make sure he/she sees it despite screen position</li>
    </ul>
  </div>

  <!-- Log output -->
  <div id="testlog"> </div>

</div>

<script type="text/javascript">
// <![CDATA[

  new Test.Unit.Runner({
    
    // replace this with your real tests
    
    setup: function() {
      
    },
    
    teardown: function() {
      
    },
    
    testTruth: function() { with(this) {
      assert(true);
    }},
    
    testInitiallyNoFlashMessage: function() { with(this) {
      assertNull($('flash_message'));
    }},
    
    testFlashMessageCreateDOMWithRightMessage: function() { with(this) {
      flash_message('Some text')
      assertNotNull($('flash_message'));
      assertVisible($('flash_message'))
      assert($('flash_message').innerHTML.match('Some text'))
    }},
    
    testFlashMessageMultipleTimes: function() { with(this) {
      flash_message('Some text')
      flash_message('No other');
      assertNotNull($('flash_message'));
      assertVisible($('flash_message'));
      assertNull($('flash_message').innerHTML.match('Some text'));
      assert($('flash_message').innerHTML.match('No other'));
      assertEqual(1, document.getElementsByClassName('flash_message').length)
    }},
  }, "testlog");
// ]]>
</script>
</body>
</html>